package com.gjsh.d_objectArr;

public class ObjectArrayTest {
    public static void main(String[] args) {
        Student[] students = new Student[5];
        students[0] = new Student("张三", 98);
        students[1] = new Student("李四", 48);
        students[2] = new Student("王五", 78);
        students[3] = new Student("小六", 88);
        students[4] = new Student("老七", 58);

        for (int j = 0; j < students.length - 1; j++) {
            for (int i = 0; i < students.length - 1 - j; i++) {
                if (students[i].getScore() > students[i + 1].getScore()) {
                    Student temp = students[i];
                    students[i] = students[i + 1];
                    students[i + 1] = temp;
                }
            }
        }
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i].getName() + " " + students[i].getScore());
        }
    }
}
